From 63e2f0bd68a7b2be82551c8640dde5f516b4dbb8 Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Mon, 27 Nov 2006 17:48:24 +0000 Subject: [PATCH] [XEN] Remove VALID_MFN(); replace uses with mfn_valid(). Signed-off-by: Keir Fraser --- xen/arch/x86/hvm/svm/svm.c | 6 +++--- xen/arch/x86/hvm/vmx/vmx.c | 8 ++++---- xen/arch/x86/mm.c | 6 +++--- xen/include/asm-x86/mm.h | 2 -- xen/include/asm-x86/shadow.h | 4 ++-- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 546c66f9fa..cfcd4293c2 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1457,7 +1457,7 @@ static int svm_set_cr0(unsigned long value) { /* The guest CR3 must be pointing to the guest physical. */ mfn = get_mfn_from_gpfn(v->arch.hvm_svm.cpu_cr3 >> PAGE_SHIFT); - if ( !VALID_MFN(mfn) || !get_page(mfn_to_page(mfn), v->domain)) + if ( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain)) { gdprintk(XENLOG_ERR, "Invalid CR3 value = %lx (mfn=%lx)\n", v->arch.hvm_svm.cpu_cr3, mfn); @@ -1642,7 +1642,7 @@ static int mov_to_cr(int gpreg, int cr, struct cpu_user_regs *regs) */ HVM_DBG_LOG(DBG_LEVEL_VMMU, "CR3 value = %lx", value); mfn = get_mfn_from_gpfn(value >> PAGE_SHIFT); - if ( !VALID_MFN(mfn) || !get_page(mfn_to_page(mfn), v->domain)) + if ( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain)) goto bad_cr3; old_base_mfn = pagetable_get_pfn(v->arch.guest_table); @@ -1672,7 +1672,7 @@ static int mov_to_cr(int gpreg, int cr, struct cpu_user_regs *regs) #if CONFIG_PAGING_LEVELS >= 3 unsigned long mfn, old_base_mfn; mfn = get_mfn_from_gpfn(v->arch.hvm_svm.cpu_cr3 >> PAGE_SHIFT); - if ( !VALID_MFN(mfn) || + if ( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain) ) goto bad_cr3; diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 2ddb3610f8..15614608fc 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -1203,7 +1203,7 @@ static int vmx_world_restore(struct vcpu *v, struct vmx_assist_context *c) */ HVM_DBG_LOG(DBG_LEVEL_VMMU, "CR3 c->cr3 = %x", c->cr3); mfn = get_mfn_from_gpfn(c->cr3 >> PAGE_SHIFT); - if ( !VALID_MFN(mfn) || !get_page(mfn_to_page(mfn), v->domain) ) + if ( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain) ) goto bad_cr3; old_base_mfn = pagetable_get_pfn(v->arch.guest_table); v->arch.guest_table = pagetable_from_pfn(mfn); @@ -1389,7 +1389,7 @@ static int vmx_set_cr0(unsigned long value) * The guest CR3 must be pointing to the guest physical. */ mfn = get_mfn_from_gpfn(v->arch.hvm_vmx.cpu_cr3 >> PAGE_SHIFT); - if ( !VALID_MFN(mfn) || !get_page(mfn_to_page(mfn), v->domain) ) + if ( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain) ) { gdprintk(XENLOG_ERR, "Invalid CR3 value = %lx (mfn=%lx)\n", v->arch.hvm_vmx.cpu_cr3, mfn); @@ -1599,7 +1599,7 @@ static int mov_to_cr(int gp, int cr, struct cpu_user_regs *regs) */ HVM_DBG_LOG(DBG_LEVEL_VMMU, "CR3 value = %lx", value); mfn = get_mfn_from_gpfn(value >> PAGE_SHIFT); - if ( !VALID_MFN(mfn) || !get_page(mfn_to_page(mfn), v->domain) ) + if ( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain) ) goto bad_cr3; old_base_mfn = pagetable_get_pfn(v->arch.guest_table); v->arch.guest_table = pagetable_from_pfn(mfn); @@ -1627,7 +1627,7 @@ static int mov_to_cr(int gp, int cr, struct cpu_user_regs *regs) #if CONFIG_PAGING_LEVELS >= 3 unsigned long mfn, old_base_mfn; mfn = get_mfn_from_gpfn(v->arch.hvm_vmx.cpu_cr3 >> PAGE_SHIFT); - if ( !VALID_MFN(mfn) || + if ( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain) ) goto bad_cr3; diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index b87bc97c5b..6980960a71 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -431,7 +431,7 @@ int map_ldt_shadow_page(unsigned int off) gmfn = l1e_get_pfn(l1e); mfn = gmfn_to_mfn(d, gmfn); - if ( unlikely(!VALID_MFN(mfn)) ) + if ( unlikely(!mfn_valid(mfn)) ) return 0; okay = get_page_and_type(mfn_to_page(mfn), d, PGT_ldt_page); @@ -2847,8 +2847,8 @@ long do_update_descriptor(u64 pa, u64 desc) LOCK_BIGLOCK(dom); - if ( !VALID_MFN(mfn = gmfn_to_mfn(dom, gmfn)) || - (((unsigned int)pa % sizeof(struct desc_struct)) != 0) || + mfn = gmfn_to_mfn(dom, gmfn); + if ( (((unsigned int)pa % sizeof(struct desc_struct)) != 0) || !mfn_valid(mfn) || !check_descriptor(&d) ) { diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 1d199022a9..93d96df4fd 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -269,8 +269,6 @@ int check_descriptor(struct desc_struct *d); #define gmfn_to_mfn(_d, gpfn) mfn_x(sh_gfn_to_mfn(_d, gpfn)) #define INVALID_MFN (~0UL) -#define VALID_MFN(_mfn) (!((_mfn) & (1U<<31))) - #ifdef MEMORY_GUARD void memguard_init(void); diff --git a/xen/include/asm-x86/shadow.h b/xen/include/asm-x86/shadow.h index 0d8b58e6d9..4b2c3b41f0 100644 --- a/xen/include/asm-x86/shadow.h +++ b/xen/include/asm-x86/shadow.h @@ -218,7 +218,7 @@ TYPE_SAFE(unsigned long,mfn) static inline int valid_mfn(mfn_t m) { - return VALID_MFN(mfn_x(m)); + return mfn_valid(mfn_x(m)); } static inline mfn_t @@ -665,7 +665,7 @@ static inline int mmio_space(paddr_t gpa) { unsigned long gfn = gpa >> PAGE_SHIFT; - return !VALID_MFN(mfn_x(sh_gfn_to_mfn_current(gfn))); + return !mfn_valid(mfn_x(sh_gfn_to_mfn_current(gfn))); } static inline l1_pgentry_t -- 2.30.2